<template>
  <el-dropdown trigger="click" class="international" @command="handleSetTheme">
    <div>
      <svg-icon class-name="international-icon" icon-class="theme" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="theme===''" command="">默认主题</el-dropdown-item>
      <el-dropdown-item :disabled="theme==='theme-star'" command="theme-star">炫彩主题</el-dropdown-item>
      <el-dropdown-item :disabled="theme==='theme-black'" command="theme-black">黑色主题</el-dropdown-item>
      <el-dropdown-item :disabled="theme==='theme-white'" command="theme-white">白色主题</el-dropdown-item>
      <el-dropdown-item :disabled="theme==='theme-gradual'" command="theme-gradual">渐变主题</el-dropdown-item>
      <!--<el-dropdown-item :disabled="theme==='theme-gray'" command="theme-gray">灰色主题</el-dropdown-item>-->
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  computed: {
    theme() {
      document.body.className = this.$store.getters.theme
      return this.$store.getters.theme
    }
  },
  methods: {
    handleSetTheme(theme) {
      this.$store.dispatch('setTheme', theme)
      this.$message({
        message: 'Switch Theme Success',
        type: 'success'
      })
    }
  }
}
</script>

<style scoped>
  .international-icon {
    font-size: 20px;
    cursor: pointer;
    vertical-align: -5px!important;
  }
</style>

